using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using DodongosQuest.Screens;
using DodongosQuest.Screens.Gameplay;

namespace DodongosQuest
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        public static ContentManager ContentManager;
        private GraphicsDeviceManager _graphics;
        public static SpriteBatch SpriteBatch;
        private IScreen _currentScreen;
        public static Game GameInstance;

        SpriteBatch spriteBatch;

        public Game1()
        {
            GameInstance = this;
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            ContentManager = Content;

            _graphics.PreferredBackBufferWidth = 1024;
            _graphics.PreferredBackBufferHeight = 768;
        }

        protected override void Initialize()
        {
            this.Window.Title = "Dodongo's Quest v0.0.0";
            this.IsMouseVisible = true;
            _currentScreen = new GameplayScreen();

            base.Initialize();
        }

        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {

            _currentScreen.Update(gameTime);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, DepthStencilState.Default, RasterizerState.CullNone);

            _currentScreen.Draw(gameTime);

            SpriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
